package com.htt.app.babau.dialog;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;

public class MyAlertDialog {
	/*
	 *  show alert dialog
	 */
	public static void alert(Context ctx, String title, String message) {
		
		AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
		builder.setTitle(title);
		builder.setMessage(message);
		
		builder.setCancelable(true);
		builder.setPositiveButton(android.R.string.ok, new OnClickListener() {
			
			@Override
			public void onClick(DialogInterface dialog, int which) {
				// TODO Auto-generated method stub
				
			}
		}
		);
		
		builder.create();
		builder.show();
		
	}
	
	/*
	 *  show alert dialog
	 *  when click button Ok, activity will be call function finish()
	 */
	public static void alertActivty(final Activity activity, String title, String message) {
		
		AlertDialog.Builder builder = new AlertDialog.Builder(activity);
		builder.setTitle(title);
		builder.setMessage(message);
		
		builder.setCancelable(true);
		builder.setPositiveButton(android.R.string.ok, new OnClickListener() {
			
			@Override
			public void onClick(DialogInterface dialog, int which) {
				// TODO Auto-generated method stub
				activity.finish();
			}
		}
		);
		
		builder.create();
		builder.show();
		
	}
	
}
